{% extends "base.html" %}

{% block title %}邀请成员 - {{ circle.name }} - 墨韵图书共享平台{% endblock %}

{% block content %}
<div class="container py-4">
    <div class="row">
        <div class="col-md-8 mx-auto">
            <div class="card ink-card">
                <div class="card-header ink-header d-flex justify-content-between align-items-center">
                    <h5 class="mb-0">邀请成员加入圈子 "{{ circle.name }}"</h5>
                    <a href="{{ url_for('circle_detail', circle_id=circle.id) }}" class="btn btn-sm btn-outline-secondary">
                        <i class="fas fa-arrow-left"></i> 返回圈子
                    </a>
                </div>
                <div class="card-body">
                    <p class="mb-4">输入学生学号进行邀请。只有存在于系统中的学号才能被邀请。</p>
                    
                    <form action="{{ url_for('invite_to_circle', circle_id=circle.id) }}" method="POST">
                        <div class="mb-3">
                            <label for="student_id" class="form-label">学号</label>
                            <input type="text" class="form-control" id="student_id" name="student_id" required>
                            <div class="form-text">请输入完整的学号</div>
                        </div>
                        
                        <div class="d-grid gap-2">
                            <button type="submit" class="btn btn-primary ink-btn">
                                <i class="fas fa-user-plus"></i> 发送邀请
                            </button>
                        </div>
                    </form>
                </div>
            </div>
            
            <div class="card ink-card mt-4">
                <div class="card-header ink-header">
                    <h5 class="mb-0">当前成员</h5>
                </div>
                <div class="list-group list-group-flush">
                    {% for member in circle.members %}
                    <div class="list-group-item d-flex justify-content-between align-items-center">
                        <div class="d-flex align-items-center">
                            {% if member.avatar and member.avatar != 'default.png' %}
                            <img src="{{ url_for('static', filename='avatars/' + member.avatar) }}" 
                                class="rounded-circle me-3" style="width: 40px; height: 40px; object-fit: cover;">
                            {% else %}
                            <div class="rounded-circle bg-secondary text-white d-flex align-items-center justify-content-center me-3" 
                                style="width: 40px; height: 40px;">
                                {{ member.username[0] }}
                            </div>
                            {% endif %}
                            <div>
                                <h6 class="mb-0">{{ member.username }}</h6>
                                <small class="text-muted">{{ member.student_id }}</small>
                            </div>
                        </div>
                        <span class="badge {% if member.id == circle.teacher_id %}bg-primary{% else %}bg-secondary{% endif %}">
                            {% if member.id == circle.teacher_id %}教师{% else %}学生{% endif %}
                        </span>
                    </div>
                    {% else %}
                    <div class="list-group-item text-center text-muted">
                        暂无成员
                    </div>
                    {% endfor %}
                </div>
            </div>
        </div>
    </div>
</div>

<style>
.ink-card {
    border: none;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.ink-header {
    background-color: #f8f9fa;
    border-bottom: none;
    padding: 1rem 1.5rem;
}

.ink-btn {
    border-radius: 5px;
    padding: 0.5rem 1.5rem;
}
</style>
{% endblock %} 